import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      // 将首页重定向到欢迎界面
      redirect: '/welcome',
      children: [
        {
          path: 'users',
          name: 'users',
          component: () => import('./views/Users.vue')
        },
        {
          path: 'welcome',
          name: 'welcome',
          component: () => import('./views/Welcome.vue')
        },
        {
          path: 'rights',
          name: 'rights',
          component: () => import('./views/auth/Rights.vue')
        },
        {
          path: 'roles',
          name: 'roles',
          component: () => import('./views/auth/Roles.vue')
        },
        {
          path: 'goods',
          name: 'goods',
          component: () => import('./views/goods/List.vue')
        },
        {
          path: 'add',
          name: 'add',
          component: () => import('./views/goods/Add.vue')
        },
        {
          path: 'categories',
          name: 'categories',
          component: () => import('./views/goods/Categories.vue')
        },
        {
          path: 'reports',
          name: 'reports',
          component: () => import('./views/statistics/reports.vue')
        },
        {
          path: 'demo',
          name: 'demo',
          component: () => import('./views/demo/Demo.vue')
        },
        {
          path: 'orders',
          name: 'orders',
          component: () => import('./views/order/Order.vue')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "login" */ './views/Login.vue')
    }
  ]
})
